package com.church.daoimpl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.church.dao.CurriculumListDao;
import com.church.db.CurriculumList;

public class CurriculumListDaoImpl extends HibernateDaoSupport implements CurriculumListDao {

	@Override
	public String saveCurriculumList(CurriculumList cl) {
		this.getHibernateTemplate().save(cl);
		return "success";
	}

	@Override
	public String updateCurriculumList(CurriculumList cl) {
		this.getHibernateTemplate().update(cl);
		return "success";
	}

	@Override
	public List<CurriculumList> getAllCurriculumList() {
		return this.getHibernateTemplate().find("from CurriculumList where state!='3'");
	}

	@Override
	public List<CurriculumList> getCurriculumListByCuId(int id) {
		return this.getHibernateTemplate().find("from CurriculumList where state!='3' and curriculumId='"+id+"'");
	}

	@Override
	public CurriculumList getCurriculumListById(int id) {
		List<CurriculumList> list= this.getHibernateTemplate().find("from CurriculumList where state!='3' and id='"+id+"'");
		if(list.size()>0)
		{
			return list.get(0);
		}
		return null;
	}

	@Override
	public List<CurriculumList> getCurriculumListByUserName(String userName) {
		return this.getHibernateTemplate().find("from CurriculumList where state!='3' and userName='"+userName+"'");
	}

}
